package com.xiashitech.agent.instrumentation.apachehttpclient;

import com.xiashitech.agent.utils.JsonUtil;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpUriRequest;

import java.io.InputStream;

public class ApacheHttpClientHandler {
    public static String HttpClientHandle(HttpUriRequest request, Object result) {
        try {
            InputStream inputStream = ((HttpResponse) result).getEntity().getContent();
            byte[] bytes = new byte[0];
            bytes = new byte[inputStream.available()];
            inputStream.read(bytes);
            String str = new String(bytes);
            System.out.println("###############"+str);
//            Field[] declaredFields = result.getClass().getDeclaredFields();
//            for (Field declaredField : declaredFields) {
//                Object value =   declaredField.get(result);
//                System.out.println("responseString0");
//                int b =0;
//                System.out.println("responseString1");
//
//            }
//            //String responseString = EntityUtils.toString(response.getEntity());
            System.out.println("responseString");
        }
        catch (Throwable e){
            e.printStackTrace();
        }

        return "";
    }
}
